﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MRSite.Common.Extensions
{
    public static class CollectionExtensions
    {
        public static bool IsNullOrEmpty<T>(this ICollection<T> container)
        {
            return container == null || container.Count <= 0;
        }

        public static bool AddNotContained<T>(this ICollection<T> container, T item)
        {
            if (container == null)
            {
                throw new ArgumentNullException($"{container.GetType().Name} is null!");
            }
            if (container.Contains(item))
            {
                return false;
            }
            container.Add(item);
            return true;
        }
    }
}
